#!/bin/sh
set -e

QMAKE_ARGS=""

if [ -n "$CC" ]; then
    QMAKE_ARGS="$QMAKE_ARGS QMAKE_CC=$CC"
fi


if [ -n "$CXX" ]; then
    QMAKE_ARGS="$QMAKE_ARGS QMAKE_CXX=$CXX"
fi

case "$CONFIG" in
full*)
    QMAKE_ARGS="$QMAKE_ARGS QXMPP_USE_DOXYGEN=1 QXMPP_USE_OPUS=1 QXMPP_USE_SPEEX=1 QXMPP_USE_THEORA=1 QXMPP_USE_VPX=1"
    ;;
esac

case "$CONFIG" in
*debug*)
    QMAKE_ARGS="$QMAKE_ARGS CONFIG+=debug"
    ;;
esac

case "$CONFIG" in
*static*)
    QMAKE_ARGS="$QMAKE_ARGS QXMPP_LIBRARY_TYPE=staticlib"
    ;;
esac

# compile
qmake $QMAKE_ARGS
make VERBOSE=1

# run tests
make check
